var loginToken = null;

(function($, owner) {

	owner.create_order = function(order) {
		owner.get_local_state();
		var url = ORDER_API + '/create.do';
		order.loginToken = loginToken;
		console.log(JSON.stringify(order))
		return requestService.httpPost(url, order);
	}

	owner.find_order = function(id) {
		
		var url = ORDER_API + '/find.do';
		var parms = {
			id: id,
			
		}
		return requestService.httpGet(url, parms);
	}
	owner.close_order = function(order) {
		var url = ORDER_API + '/closeOrder.do';
		return requestService.httpGet(url, order);

	}
	owner.pay = function(order) {
		var url = ORDER_API + '/pay.do';
		return requestService.httpGet(url, order);
	}

	owner.delete_order = function(orderId) {
		var url = ORDER_API + '/delete.do';
		var parms = {
			orderId: orderId
		}
		return requestService.httpGet(url, parms);
	}

	owner.find_detatil = function(orderId) {
		var url = ORDER_API + '/findDetatil.do';
		var parms = {
			orderId: orderId
		}
		return requestService.httpGet(url, parms);
	}

	owner.find_list = function() {
		owner.get_local_state();
		var parms = {
			loginToken: loginToken
		}
		var url = ORDER_API + '/findMyOrderList.do';
		return requestService.httpGet(url, parms);

	}

	owner.get_local_state = function() {
		var state = JSON.parse(localStorage.getItem('$state'));
		if(state != null) {
			loginToken = state.loginToken;
		}
	}

}(mui, window.orderService = {}));